package cn.iocoder.yudao.module.alipay.dal.mysql.cpssource;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.alipay.dal.dataobject.cpssource.CpsSourceDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.alipay.controller.admin.cpssource.vo.*;

/**
 * 渠道标识 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface CpsSourceMapper extends BaseMapperX<CpsSourceDO> {

    default PageResult<CpsSourceDO> selectPage(CpsSourcePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CpsSourceDO>()
                .eqIfPresent(CpsSourceDO::getUserId, reqVO.getUserId())
                .eqIfPresent(CpsSourceDO::getSourceContent, reqVO.getSourceContent())
                .eqIfPresent(CpsSourceDO::getSort, reqVO.getSort())
                .eqIfPresent(CpsSourceDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(CpsSourceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CpsSourceDO::getId));
    }

    default List<CpsSourceDO> selectList(CpsSourceExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<CpsSourceDO>()
                .eqIfPresent(CpsSourceDO::getUserId, reqVO.getUserId())
                .eqIfPresent(CpsSourceDO::getSourceContent, reqVO.getSourceContent())
                .eqIfPresent(CpsSourceDO::getSort, reqVO.getSort())
                .eqIfPresent(CpsSourceDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(CpsSourceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CpsSourceDO::getId));
    }

    default List<CpsSourceDO> getListByUserId(String userId){
        return selectList(new LambdaQueryWrapperX<CpsSourceDO>()
                .eqIfPresent(CpsSourceDO::getUserId, userId));
    };
}
